<template>
	<view style="width: 100%; height: 500px; ">
		 <u--form :model="auctionDetails" ref="addaddressform"  class="demo-ruleForm" style="margin-top:48px;">
			<u-row>
				<u-col span=3><p style="float: left; line-height: 40px;margin-left: 10px;">起拍价：</p></u-col>
				<u-col span=9> 
				<u--input
				style="width: 250px;  "
			    placeholder="请输入起拍价钱"
			    border="surround"
			    v-model="auctionDetails.startPrice"
				></u--input>
				</u-col>
			</u-row>
			<u-divider text=""></u-divider>
			<u-row>
				<u-col span=3><p style="float: left; line-height: 40px;margin-left: 10px;">开拍时间：</p></u-col>
				<u-col span=9>
					  <u-datetime-picker
					                :show="show"
					                v-model="value1"
					                mode="datetime"
									:formatter="formatter"
									@confirm="confirm"
					        ></u-datetime-picker>
			<view @click="show = true">
			<u--input
				disabled
				style="width: 250px;  "
			    placeholder="请选择开拍时间:"
			    border="surround"
			    v-model="auctionDetails.startTime"
				></u--input></view></u-col>
			</u-row> 
			<u-divider text=""></u-divider>
			<u-row>
				<u-col span=3><p style="float: left; line-height: 40px;margin-left: 10px;">结束时间：</p></u-col>
				<u-col span=9>
					<u-datetime-picker
					              :show="show1"
					              v-model="value1"
					              mode="datetime"
								:formatter="formatter"
								@confirm="confirmm"
					      ></u-datetime-picker>
					<view @click="show1 = true">
					<u--input
					disabled
					 v-model="auctionDetails.endTime"
					placeholder="请选择结束拍卖时间:"
					style="width: 250px;"
				
					confirmm="confirmm"
					ref="uPicker"
				></u--input>
					</view>
					</u-col>
			</u-row> 
			<u-divider text=""></u-divider>
			</u-row> 
			 <u-button class ="que" type="primary"  shape="circle" :plain="true"  @click="xinxi('addaddressform')" style="width: 150px;margin-top: 50px; height: 45px;">保存拍卖信息</u-button>
			 </u--form> 
	</view>
</template>
<script>
	export default {
		data() {
			return {
					  show: false,
					  show1:false,
					  value1: Number(new Date()),
					  id:'',
					auctionDetails:{
							checkStatus:4,
							id:'',
							startPrice:'',
							startTime:'',
							endTime:'',
							
					},
			}
		},
		onLoad: function(option) {
				 
		// 获取上一页面传输过来的参数
		    this.auctionDetails.id = parseInt( option.id)
		 console.log("aaa"+this.id)
		   },
		methods: {
			
			xinxi(){
				var that = this
					uni.request({
							url: "http://"+that.$host+":"+that.$port+"/publish/publishUpdate",
							data:that.auctionDetails,
							method: 'POST',
							dataType: 'json',
				success: (res) => {
						uni.showToast({ //添加成功提示
						 icon: 'success',
						 title: '提交成功',
						 // 显示时长时间为1000秒
						 duration: 1000
						})
						this.timer = setInterval(function () { 
							uni.navigateBack({data:1})
						},1000) 
				
				},  
							});
			},
			
			formatter(type, value) {
                if (type === 'year') {
                    return `${value}年`
                }
                if (type === 'month') {
                    return `${value}月`
                }
                if (type === 'day') {
                    return `${value}日`
                }
                return value
            },
		
	// 回调参数为包含columnIndex、value、values
	confirm(e) {
		console.log('confirm', e)
		var date = new Date(parseInt(e.value))
		this.auctionDetails.startTime=date.getFullYear()+"/"+(date.getMonth()+1)+"/"+date.getDate()+'/'+date.getHours()+'/'+date.getMinutes()
		this.show = false
	},
	confirmm(e) {
	console.log('confirm', e)
	var date = new Date(parseInt(e.value))
	this.auctionDetails.endTime=date.getFullYear()+"/"+(date.getMonth()+1)+"/"+date.getDate()+'/'+date.getHours()+'/'+date.getMinutes()
	this.show1 = false
	}
		}
	}
</script>

<style>

</style>
